import request from "@/utils/request";

export function uploadOss(file, productId, title) {
  const formData = new FormData();
  formData.append('file', file);
  formData.append('productId', productId);
  formData.append('title', title);

  return request({
    url: "/sysOss/upload",
    method: "post",
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

// 查询数据列表
export function listOss() {
  return request({
    url: "/sysOss/list",
    method: "get",
  });
}

// 通过主键查询单条数据
export function getOss(id) {
  return request({
    url: "/sysOss/" + id,
    method: "get"
  });
}

// 分页查询
export function listOssByPage(query) {
  return request({
    url: "/sysOss/page",
    method: 'get',
    params: query
  })
}

// 新增数据
export function addOss(sysOss) {
  return request({
    url: "/sysOss",
    method: "post",
    data: sysOss
  });
}

// 编辑数据
export function updateOss(sysOss) {
  return request({
    url: "/sysOss",
    method: "put",
    data: sysOss
  });
}

// 批量删除数据
export function deleteOss(ids) {
  return request({
    url: "/sysOss/" + ids,
    method: "delete"
  });
}
